/**
 * 通用混合
 * */
export default {
    methods: {
        // 当 $route 更新时触发
        appRouteChange (to, from) {

        },
        // 时间戳转 YYYY-MM-DD HH:II:SS
        timestampToDateTime(timestamp){
            if(timestamp <= 0) return "-";
            if(timestamp < 10000000000) timestamp *= 1000;
            var date = new Date(timestamp);
            let toDate = this.toDate(date);
            let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
            let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
            let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
            return toDate + ' '+ Hour +':'+ Minute  + ':' + Sechond;
        },
        // 转 YYYY-MM-DD
        toDate(date){
            let Year = date.getFullYear();
            let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
            let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
            return Year + '-' + Moth + '-' + Day;
        }
    }
}
